<?php

declare(strict_types=1);

use App\Common\AsyncQueue\RedisDriver\RedisDriver;

return [
    'default' => [
        'driver' => Hyperf\AsyncQueue\Driver\RedisDriver::class,
        'redis' => [
            'pool' => 'default'
        ],
        'channel' => 'default',
        'timeout' => 2,
        'retry_seconds' => 5,
        'handle_timeout' => 10,
        'processes' => 1,
        'concurrent' => [
            'limit' => 5,
        ],
        'retry_times' => 3,  // 最大重试次数
//        'failed' => [
//            'log' => true,  // 任务失败后记录日志
//            'callback' => [\App\CustHub\Job\RobotMsgJob::class, 'failed'],  // 任务失败后的回调函数
//        ],
    ],
    'local' => [
        'driver' => RedisDriver::class,
        'redis' => [
            'pool' => 'default'
        ],
        'channel' => (string)env('DISTRIBUTE_SERVER_ID', uniqid()),
        'timeout' => 2,
        'retry_seconds' => 5,
        'handle_timeout' => 10,
        'processes' => 1,
        'concurrent' => [
            'limit' => 10
        ],
    ],
    'saas' => [
        'driver' => \App\Common\AsyncQueue\RedisDriver\RedisDriver::class,
        'redis' => [
            'pool' => 'saas'
        ],
        'channel' => 'custHub:saas',
        'timeout' => 2,
        'retry_seconds' => 5,
        'handle_timeout' => 60,
        'processes' => 1,
        'concurrent' => [
            'limit' => 5,
        ],
    ],
    'high_priority' => [ // 为高优先级任务单独配置
        'driver' => Hyperf\AsyncQueue\Driver\RedisDriver::class,
        'channel' => 'ch:high_priority',
        'timeout' => 2,
        'retry_seconds' => [5, 10, 15],
        'handle_timeout' => 20,
        'processes' => 5,
        'concurrent' => [
            'limit' => 30,
        ],
        'redis' => [
            'pool' => 'default',
        ],
    ],
    'low_priority' => [ // 为低优先级任务单独配置
        'driver' => Hyperf\AsyncQueue\Driver\RedisDriver::class,
        'channel' => 'ch:low_priority',
        'timeout' => 5,
        'retry_seconds' => [10, 20, 30],
        'handle_timeout' => 60,
        'processes' => 2,
        'concurrent' => [
            'limit' => 10,
        ],
        'redis' => [
            'pool' => 'default',
        ],
    ],
    'serial' => [
        'driver' => Hyperf\AsyncQueue\Driver\RedisDriver::class,
        'redis' => [
            'pool' => 'default'
        ],
        'channel' => 'serial_queue', // 队列名称
        'timeout' => 2,
        'retry_seconds' => 5,
        'handle_timeout' => 60,
        // 🚨 核心：严格顺序执行
        'processes' => 1,  // 只允许一个进程消费
        'concurrent' => [
            'limit' => 1,   // 单进程内只允许一个协程处理任务
        ],

        'retry_times' => 3,
    ],
];
